function editPwd(){
     var id = $("#id").val();
     var oldPassword = $("#oldPwd").val();
     var oldPwd = $("#old-password").val();//旧密码
     var newPwd = $("#new-password").val();//新密码
     var confirmPwd = $("#confirm-password").val();//确认密码
     var protocol = window.location.protocol;
     var host = window.location.host;
     var pwdCheck = /^[a-zA-Z]\w{5,17}$/;
     if (oldPassword != oldPwd){
         layer.open({
             title: '提示信息',
             anim: 0,
             resize:false,//是否可以拉伸  默认true
             icon: 2,
             shadeClose: true,
             skin: 'layui-layer-molv',
             content: "旧密码不正确，请重新输入！",
             yes:function (index){
                 $('#old-password').focus();
                 layer.close(index);
             }
         });
         return "";
     }
     if (!pwdCheck.test(newPwd)){
         layer.open({
             title: '提示信息',
             anim: 0,
             resize:false,//是否可以拉伸  默认true
             icon: 2,
             shadeClose: true,
             skin: 'layui-layer-molv',
             content: "新密码以字母开头，长度在6-18之间，只能包含字符、数字和下划线！",
             yes:function (index){
                 $('#new-password').focus();
                 layer.close(index);
             }
         });
         return "";
     }
     if (newPwd != confirmPwd){
         layer.open({
             title: '提示信息',
             anim: 0,
             resize:false,//是否可以拉伸  默认true
             icon: 2,
             shadeClose: true,
             skin: 'layui-layer-molv',
             content: "新密码和确认密码不一致！",
             yes:function (index){
                 $('#new-password').focus();
                 $('#confirm-password').focus();
                 layer.close(index);
             }
         });
         return "";
     }
     else {
         $.ajax({
             type : 'POST',
             url : '/editPwd',
             data : {id:id,oldPwd:oldPwd,newPwd:newPwd,confirmPwd:confirmPwd},
             success:function (data) {

                 if (data == "OK"){
                     layer.msg('修改成功，请重新登录', {
                         icon: 1,
                         shadeClose: true,
                         skin: 'layui-layer-molv',
                         time: 2000 //2秒关闭（如果不配置，默认是3秒）
                     }, function(){
                         window.location.href = protocol+"//"+host+"/logout";
                     });

                 }else {
                     layer.open({
                         title: '提示信息',
                         anim: 0,
                         resize:false,//是否可以拉伸  默认true
                         icon: 2,
                         shadeClose: true,
                         skin: 'layui-layer-molv',
                         content: data
                     });
                 }
             },
             error: function (e) {
                 console.log(e)
             }
         });
     }

}
//个人中心修改信息
function userEdit(){
    var id = $("#id").val();
    var name = $("#name").val();
    var email = $("#email").val();
    var tel = $("#tel").val();
    var userName = $("#userName").val();
    var reg_name = /^[\u4e00-\u9fa5]{2,10}$/;
    var protocol = window.location.protocol;
    var host = window.location.host;
    if (!reg_name.test(name)){
        layer.open({
            title: '提示信息',
            anim: 0,
            resize:false,//是否可以拉伸  默认true
            icon: 2,
            shadeClose: true,
            skin: 'layui-layer-molv',
            content: "姓名只能由2-10个中文字符组成！",
            yes:function (index){
                $('#name').focus();
                layer.close(index);
            }
        });
        return "";
    }
    var reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
    if (!reg_tel.test(tel)) {
        layer.open({
            title: '提示信息',
            anim: 0,
            resize:false,//是否可以拉伸  默认true
            icon: 2,
            shadeClose: true,
            skin: 'layui-layer-molv',
            content: "请填写正确的手机号码！",
            yes:function (index){
                $('#tel').focus();
                layer.close(index);
            }
        });
        return "";
    }
    var reg_email = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
    if (!reg_email.test(email)) {
        layer.open({
            title: '提示信息',
            anim: 0,
            resize:false,//是否可以拉伸  默认true
            icon: 2,
            shadeClose: true,
            skin: 'layui-layer-molv',
            content: "请填写正确的邮箱！",
            yes:function (index){
                $('#email').focus();
                layer.close(index);
            }
        });
        return "";
    }

    $.ajax({
        type : 'POST',
        url : '/userEdit',
        data : {id:id,name:name,email:email,tel:tel},
        success:function (data) {

            if (data == "OK"){
                layer.msg('操作成功', {
                    icon: 1,
                    shadeClose: true,
                    skin: 'layui-layer-molv',
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    window.location.href = window.location.href;
                });

            }else {
                layer.open({
                    title: '提示信息',
                    anim: 0,
                    resize:false,//是否可以拉伸  默认true
                    icon: 2,
                    shadeClose: true,
                    skin: 'layui-layer-molv',
                    content: data
                });
            }
        },
        error: function (e) {
            console.log(e)
        }
    });

}